package fr.emse.tatiana.graphical;
import java.util.Vector;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.EditorActionBarContributor;

import fr.emse.tatiana.TatianaConstants;


public class GraphicalEditorContributor extends EditorActionBarContributor {

	Vector<ExportToImageAction> export;

	public GraphicalEditorContributor() {
		super();

		export = new Vector<ExportToImageAction>();

		export.add(new ExportToImageAction(SWT.IMAGE_PNG,"png..."));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
	 */
	@Override
	public void contributeToMenu(IMenuManager menuManager) {
		super.contributeToMenu(menuManager);
		IMenuManager fileMenu = menuManager
		.findMenuUsingPath(IWorkbenchActionConstants.M_FILE);

		final IMenuManager exportMenu = fileMenu.findMenuUsingPath(TatianaConstants.M_EXPORT_ACTION);
		for (IAction action : export) {
			exportMenu.add(action);
		}

	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.part.EditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
	 */
	@Override
	public void setActiveEditor(IEditorPart targetEditor) {
		super.setActiveEditor(targetEditor);

		for (ExportToImageAction action : export) {
			action.setEditor(targetEditor);
		}

	}
}
